package com.loan.common;
import com.jfinal.core.JFinal;
import com.loan.model.Param;
import com.loan.util.Str;

public class CONST { 
	public final static String SUCCESS = "success"; 
	public final static String ERROR = "error";    
	public final static String URL = "https://www.bajiehuishou.com";   
	public final static String ROOT = "/opt/apache-tomcat-9.0.8/webapps/ROOT";   
	public final static String AES_KEY = "bjhs_pretty_well"; 
	 
	public static void setAttr(String key, String val){
		JFinal.me().getServletContext().setAttribute(key, val);
	}
	  
	public static String getAttr(String key){
		Object s = JFinal.me().getServletContext().getAttribute(key);
		return s!=null ? s.toString() : "";
	}
	 
	public static String find(String name){
		if(Str.isBlank(CONST.getAttr(name))){
			Param pm = Param.dao.findFirst("select * from param where name=?",name);
			CONST.setAttr(name, pm.getValue());		
		}		
		return CONST.getAttr(name);
	}
	
	public static void removeAttr(String key){
		JFinal.me().getServletContext().removeAttribute(key);
	}
}    